package com.example.layoutandlistview;



import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class FileAdapter extends ArrayAdapter<FileDownload>{
	private ArrayList<FileDownload> files = new ArrayList<FileDownload>();
	LayoutInflater inflater;
	
	public FileAdapter(Context context, int textViewResourceId,
			ArrayList<FileDownload> files) {
		super(context, textViewResourceId, files);
		this.files = files;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
				v = inflater.inflate(R.layout.item_file_download, null);
		}

		FileDownload file = files.get(position);
		if (file != null) {
			TextView fileName = (TextView) v.findViewById(R.id.fileName);
			TextView downloadLink = (TextView) v.findViewById(R.id.createAt);
			if (fileName != null) {
				fileName.setText(file.getFileName());
			}
			if(downloadLink!= null){
				downloadLink.setText("Description");
			}
				
		}

		return v;
	}
}
